/*
 * Copyright (c) 2025 CAX Conversion Project
 */
package com.comac.ins.isfd.constant.enums;

import com.comac.ins.common.core.utils.StringUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 算法类型枚举类
 *
 * @author hxloongs
 * @date 2024-7-15
 */
@AllArgsConstructor
@Getter
public enum IsfdAnalysisTypeEnum {

    APPLICATION_TYPE("application_type", "应用类型"),
    CLASSIFICATION_TYPE("classification_type", "classification类型"),
    MATERIAL_TYPE("material_type", "材料类型");
    private final String value;
    private final String desc;

    public static String getDescByValue(String value) {
        IsfdAnalysisTypeEnum isfdAnalysisMaterialTypeEnum = forValue(value);
        if (isfdAnalysisMaterialTypeEnum == null) {
            return null;
        }
        return isfdAnalysisMaterialTypeEnum.getDesc();
    }

    public static IsfdAnalysisTypeEnum forValue(String value) {
        if (StringUtils.isBlank(value)) {
            return null;
        }
        for (IsfdAnalysisTypeEnum isfdAnalysisClassificationTypeEnum : IsfdAnalysisTypeEnum.values()) {
            if (isfdAnalysisClassificationTypeEnum.getValue().equals(value)) {
                return isfdAnalysisClassificationTypeEnum;
            }
        }
        return null;
    }

    public static IsfdAnalysisTypeEnum forDesc(String desc) {
        if (desc == null) {
            return null;
        }
        for (IsfdAnalysisTypeEnum isfdAnalysisClassificationTypeEnum : IsfdAnalysisTypeEnum.values()) {
            if (desc.equals(isfdAnalysisClassificationTypeEnum.getDesc())) {
                return isfdAnalysisClassificationTypeEnum;
            }
        }
        return null;
    }
}
